package com.joe.demo.nio.io;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @Description
 * @Author gaojw
 * @Date 2024-08-28
 */
@Slf4j
public class WriteClient {

    public static void main(String[] args) throws IOException {
        final SocketChannel client = SocketChannel.open();
        client.connect(new InetSocketAddress("localhost", 8080));
        while (true){
            final ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
            final int read = client.read(buffer);
            log.info("接收到的数据个数：{}", read);
            buffer.clear();
        }


    }
}
